package cn.xmstore.controller;

import cn.xmstore.entity.Account;
import cn.xmstore.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Author aeolia
 * @Date 2021/8/12 15:15
 */

@Controller
@RequestMapping("/account2")
public class Account2Controller {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/findAll")
    private String findAll() {
        System.out.println("视图层：查询所有账户信息");
        List<Account> accounts = accountService.findAll();
        try {
            if (accounts != null) {
                for (Account account : accounts) {
                    System.out.println(account);
                }
            }
            return "success";
        } catch (Exception e) {
            return "error";
        }
    }


}
